var findMaxForm = function(strs, m, n) {
  const len = strs.length;
  const dp = new Array(m + 1).fill(0).map(() => new Array(n + 1).fill(0));
  for (let i = 0; i < len; i++) {
    const zeros = (strs[i].match(/0/g) || []).length;
    const ones = strs[i].length - zeros;
    for (let j = m; j >= zeros; j--) {
      for (let k = n; k >= ones; k--) {
        dp[j][k] = Math.max(dp[j][k], dp[j - zeros][k - ones] + 1);
      }
    }
  }
  return dp[m][n];
};


const strs = ["10", "0001", "111001", "1", "0"], m = 5, n = 3;
console.log(findMaxForm(strs, m, n)); // Output: 4